/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package muets;

import java.net.URL;
import java.util.ArrayList;
import model.CIMBadArgument;
/*import org.sblim.wbem.cim.CIMNameSpace;
import org.sblim.wbem.client.CIMClient;
import org.sblim.wbem.client.PasswordCredential;
import org.sblim.wbem.client.UserPrincipal;*/

/**
 *
 * @author Dudu
 */
public class CIMServer {

	private String nameSpace;
	private String host;
	private String user;
	private String pwd;



	public CIMServer(String nameSpace,String host,String user, String password) throws CIMBadArgument,Exception {
		this.host = host;
		this.nameSpace = nameSpace;
		this.user = user;
		pwd = password;
	}

    public String getHost() {
        return host;
    }

    public String getNameSpace() {
        return nameSpace;
    }

    public String getPwd() {
        return pwd;
    }

    public String getUser() {
        return user;
    }
//Sample data for tests
    public ArrayList<IPSecPolicy> enumIPSecPolicies() throws Exception{
        ArrayList<IPSecPolicy> policies=new ArrayList<IPSecPolicy>();
        IPSecPolicy p1=new IPSecPolicy("lol", "192.168.1.100", "192.168.2.100", "any", "out", "ipsec", "", "", "esp", "transport", "require");
        IPSecPolicy p2=new IPSecPolicy("lol", "www.google.com", "127.0.0.1", "any", "out", "discard", "168.192.0.2", "1.2.3.4", "esp", "tunnel", "unique");
        IPSecPolicy p3=new IPSecPolicy("lol", "192.168.1.101", "123.56.0.84", "any", "out", "ipsec", "", "", "esp", "transport", "require");
        IPSecPolicy p4=new IPSecPolicy("lol", "127.0.0.1", "www.enseeiht.fr", "any", "out", "none", "1.1.1.1", "2.2.2.2", "esp", "tunnel", "default");
        IPSecPolicy p5=new IPSecPolicy("lol", "172.45.2.17", "192.168.2.100", "any", "out", "discard", "", "", "esp", "transport", "use");
        policies.add(p1);
        policies.add(p2);
        policies.add(p3);
        policies.add(p4);
        policies.add(p5);
return policies;


    }

    public ArrayList<IPSecRule> enumIPSecRules() throws Exception{
        ArrayList<IPSecRule> rules=new ArrayList<IPSecRule>();
        IPSecRule r1=new IPSecRule("lol", "192.168.1.100", "192.168.2.100", "AH", "transport", "15700", "hmac-md5", "9876543210987654");
        IPSecRule r2=new IPSecRule("lol", "127.0.0.1", "192.168.2.100", "AH", "transport", "1", "hmac-md5", "1598746230159730");
        IPSecRule r3=new IPSecRule("lol", "192.168.1.100", "www.enseeiht.fr", "ESP", "tunnel", "250", "hmac-md5", "1234567890123456");
        IPSecRule r4=new IPSecRule("lol", "168.172.0.2", "127.0.0.1", "ESP", "transport", "8642", "hmac-md5", "1234567890123456");
        rules.add(r1);
        rules.add(r2);
        rules.add(r3);
        rules.add(r4);
        return rules;
    }

    public ArrayList<IPTableRule> enumIPTableRules() throws Exception{
        ArrayList<IPTableRule>rules=new ArrayList<IPTableRule>();
        IPTableRule r1=new IPTableRule("lol","INPUT", "192.168.1.100", "192.168.2.100", "TCP", "80", "21", "ACCEPT");
	rules.add(r1);
        return rules;
    }

    public void register(IPSecPolicy p) throws Exception{
        System.out.println("ajout de "+p.getName()+" a la CIMOM");
    }

    public void register(IPSecRule r) throws Exception{
        System.out.println("ajout de "+r.getName()+" a la CIMOM");
    }

    public void register(IPTableRule r) throws Exception{
        System.out.println("ajout de "+r.getName()+" a la CIMOM");
    }
    public void remove(IPSecPolicy p) throws Exception{
        System.out.println("retrait de "+p.getName()+" de la CIMOM");
    }

    public void remove(IPSecRule r) throws Exception{
        System.out.println("retrait de "+r.getName()+" de la CIMOM");
    }

    public void remove(IPTableRule r) throws Exception{
        System.out.println("retrait de "+r.getName()+" de la CIMOM");
    }

}
